/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Controller;

import DB.CustomerManager;
import DB.IFCustomerManager;
import DB.IFItemManager;
import DB.IFSalesOrderManager;
import DB.IFStatusManager;
import DB.ItemManager;
import DB.SalesOrderManager;
import DB.StatusManager;
import Model.Customer;
import Model.Item;
import Model.SalesOrder;
import Model.Status;
import java.util.ArrayList;

/**
 *
 * @author kostas
 */
public class SalesOrderController implements IFSalesOrderController {

    private IFSalesOrderManager salesOrder;
    private IFItemManager itemManager;
    private IFStatusManager statusManager;
    private IFCustomerManager customerManager;

    public SalesOrderController(){
         salesOrder = new SalesOrderManager();
         itemManager = new ItemManager();
         statusManager = new StatusManager();
         customerManager = new CustomerManager();
    }

    public SalesOrder getSalesOrder(int orderId, boolean retreiveAssociations) throws IllegalArgumentException {
        return salesOrder.getSalesOrder(orderId, retreiveAssociations);
    }

    public void createSalesOrder(SalesOrder order, boolean updateAssociations) {
       salesOrder.createSalesOrder(order, updateAssociations);
    }

    public void updateSalesOrder(SalesOrder order, boolean updateAssociations) {
       salesOrder.updateSalesOrder(order, updateAssociations);
    }

    public Customer getCustomer(int customerId, boolean retreiveAssociations) throws IllegalArgumentException {
       return customerManager.getCustomer(customerId, retreiveAssociations);
    }

    public Item getItem(int itemId, boolean retreiveAssociations) throws IllegalArgumentException {
        return itemManager.getItem(itemId, retreiveAssociations);
    }

    public ArrayList<Status> getStatuses(String type) throws IllegalArgumentException {  
        return statusManager.getStatuses(type);
    }

    public Status getStatus(String name) throws IllegalArgumentException {
        return statusManager.getStatusByName(name);
    }
}
